<?php
namespace app\avikcm\controller;
use think\Db;
use think\facade\Request;
class Feedback extends Common
{
    public function initialize(){
        parent::initialize();
    }

    //意见反馈列表
    public function index(){
        if(Request::isAjax()) {
            $key = input('post.key');
            $this->assign('testkey', $key);
            $page =input('page')?input('page'):1;
            $pageSize =input('limit')?input('limit'):config('pageSize');
            $list = Db::table('feedback')->alias('a')
                ->join('users b', 'a.uid = b.id', 'left')
                ->field('a.*,b.nickname,b.mobile')
                ->where('a.content', 'like', "%" . $key . "%")
                ->order('a.id DESC')
                ->paginate(array('list_rows'=>$pageSize,'page'=>$page))
                ->toArray();
            return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$list['data'],'count'=>$list['total'],'rel'=>1];
        }
        return $this->fetch();
    }

    public function view(){
        
        $id=input('id');
        $info=db('feedback')->alias('a')
        ->join('users b', 'a.uid = b.id', 'left')
        ->field('a.*,b.nickname,b.mobile')->where(array('a.id'=>$id))->find();
        $this->assign('info',json_encode($info,true));
        $this->assign('title','查看反馈详情');
        return $this->fetch('view');
    }
    
}